import java.util.Date;
import java.util.GregorianCalendar;

import df.bean.db.conn.DBConnection;
import df.bean.db.table.BankTMBMediaClearing;
import df.bean.db.table.Batch;
import df.bean.db.table.PaymentMonthly;
import df.bean.obj.doctor.DoctorList;
import df.bean.obj.util.DialogBox;
import df.bean.obj.util.JDate;
import df.bean.obj.util.JNumber;
import df.bean.obj.util.Variables;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import df.bean.process.ProcessBankTMBPaymentMonthly;
import df.bean.process.ProcessImport;
import df.bean.process.ProcessPaymentMonthly;
import df.bean.process.ProcessReceipt;
import df.bean.process.ProcessRollBack;
import df.bean.process.ProcessTax406;
import df.bean.process.ProcessTransDaily;
import df.bean.process.ProcessTransMonthly;

/**
 *
 * @author admin
 */
public class TestMain {

    /**
     * @param args the command line arguments
     */

    public static void main(String[] args) {
    	//System.out.println(JNumber.getShowMoney(120450.3554));
    	//System.out.println(JNumber.getSaveMoney("120,450.35"));
    	//System.out.println(JNumber.getSaveMoney(450.5524));
        // TODO code application logic here
        DBConnection conn = new DBConnection();
        conn.connectToLocal();
        Variables.setHospitalCode("00001");
        Variables.setUserID("sys");
        Variables.setPassword("321");
        Batch batch = new Batch(Variables.getHospitalCode(), conn);        
        String startTime = JDate.getTime();

        //Compute Daily
        System.out.println("Start Daily Calculate");
        DoctorList drList = new DoctorList(Variables.getHospitalCode(), conn);
        drList.newDoctorForComputeDaily("20120131", "20120131", "00001");
        System.out.println("List");

        ProcessTransDaily pd = new ProcessTransDaily(conn);
        System.out.println("New Process");

        pd.setDoctorList(drList);
        System.out.println("Set List");

        System.out.println(pd.Calculate("20120131", "20120131", "00001", "01-CI12001736", "10334915/3") ? "Success" : "Fail");
        pd = null; 
        drList = null;

        // Rollback ComputeDaily
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackTrnDaily(Variables.getHospitalCode(), "20080201", "20080232")) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");

        
        // Update Receipt
//        ProcessReceipt pr = new ProcessReceipt(conn);
//        if (pr.run("2008", "02", Variables.getHospitalCode())) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
//        pr = null;
        
        // Rollback Receipt AR
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackReceiptByAR(Variables.getHospitalCode(), "2008", "02")) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
                
        //         Rollback Receipt By Payor
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackReceiptByPayor(Variables.getHospitalCode(), "2008", "02")) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
        //         Rollback Receipt
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackReceiptByDoctor(Variables.getHospitalCode(), "2008", "02")) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
        
        
        // Summary Monthly
//        drList.newAllDoctor (Variables.getHospitalCode());
//        ProcessTransMonthly pm = new ProcessTransMonthly(conn);
//        pm.setDoctorList(drList);
//        if (pm.run("2008", "02", Variables.getHospitalCode())) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
//        pm = null;
        
//         Rollback Summary Monthly
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackSummaryMonthly(Variables.getHospitalCode(), "2008", "02")) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
        
        
        // Compute Payment monthly for DF
        /*
        ProcessPaymentMonthly ppm = new ProcessPaymentMonthly(conn);
        if (ppm.run("2008", "02", Variables.getHospitalCode())) {
            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
        }else DialogBox.ShowInfo("Fail!!!");
        ppm = null;
        */
        
        // Rollback Payment Monthly for DF
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackPaymentMonthly(Variables.getHospitalCode(), "2008", "02", PaymentMonthly.PAYMENT_TYPE_DF)) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
          
        // Export to Bank for DF
//        ProcessBankTMBPaymentMonthly pb = new ProcessBankTMBPaymentMonthly(conn);
//        if (pb.run("2008", "02", "20080310", PaymentMonthly.PAYMENT_TYPE_DF, Variables.getHospitalCode())) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
//        pb = null;
        // Rollback Export to Bank for DF
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackMediaClearing(Variables.getHospitalCode(), "2008", "02", BankTMBMediaClearing.SERVICE_TYPE_PAYMENT)) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
        
          
        // Compute Summary Tax406
//        drList.newAllDoctor(Variables.getHospitalCode());
//        ProcessTax406 pt = new ProcessTax406(conn);
//        pt.setDoctorList(drList);
//        if (pt.run("2008", "06", Variables.getHospitalCode())) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
//        pt = null;
        
        // Rollback Summary Tax406
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackSummaryTax406(Variables.getHospitalCode(), "2008", "06")) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
        
        // Compute Payment monthly for Salary
//        ProcessPaymentMonthly ppm1 = new ProcessPaymentMonthly(conn);
//        if (ppm1.runForSalary("20080225", Variables.getHospitalCode())) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
//        ppm1 = null;
        // Rollback Payment monthly for Salary
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackPaymentMonthly(Variables.getHospitalCode(), "2008", "02", PaymentMonthly.PAYMENT_TYPE_SALARY)) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");  
        
        
//        // Export to Bank for Salary
//        ProcessBankTMBPaymentMonthly pb1 = new ProcessBankTMBPaymentMonthly(conn);
//        if (pb1.run("2008", "02", "20080226", PaymentMonthly.PAYMENT_TYPE_SALARY, Variables.getHospitalCode())) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
//        pb1 = null;
        // Rollback Export to Bank for Salary
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackMediaClearing(Variables.getHospitalCode(), "2008", "02", BankTMBMediaClearing.SERVICE_TYPE_PAYROLL)) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
        
        
        //////// Import ///////////
//        ProcessImport pi = new ProcessImport(conn);
//        ProcessReceipt pr = new ProcessReceipt(conn);
//        if (pi.importBill(Variables.getHospitalCode(), "20081005", "20081005") && 
//                pr.CalculateReceiptByCash(Batch.getYyyy(), Batch.getMm(), "20081005", "20081005", "201")) {
//        if (pi.importVerifyInMonth(Variables.getHospitalCode(), "20081005", "20081005")) {
//        if (pi.importVerifyRecOverMonth(Variables.getHospitalCode(), "20081005", "20081005")) {
//        if (pi.importVerifyNotRec(Variables.getHospitalCode(), "20081005", "20081005")) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");
        
        // Rollback Export to Bank for Salary
//        ProcessRollBack rb = new ProcessRollBack(conn);
//        if (rb.rollBackImportBill(Variables.getHospitalCode(), "20081005", "20081005") && 
//                rb.rollBackImportVerify(Variables.getHospitalCode(), "20081005", "20081005")) {
//            DialogBox.ShowInfo("Success!!!" + startTime + " ---> " + JDate.getTime());
//        }else DialogBox.ShowInfo("Fail!!!");

        batch = null;
        if (conn.IsOpened()) { conn.Close(); }
        
    }

}
